package com.xiyue.lenovo.datatypeoverride;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void overrideType(View view) {
        Intent intent = new Intent();
        //先为Intent设置Type属性

        //再为Intent设置Data属性，覆盖Type属性
        intent.setData(Uri.parse("lee://www.fkjava.org:8888/test"));
        Toast.makeText(this,intent.toString(),Toast.LENGTH_LONG).show();
    }

    public void overrideData(View view) {
        Intent intent = new Intent();
        //先为Intent设置Data属性
        intent.setData(Uri.parse("lee://www.fkjava.org:8888/test"));;
        //再为Intent设置Type属性，覆盖Data属性
        intent.setType("abc/xyz");
        Toast.makeText(this,intent.toString(),Toast.LENGTH_LONG).show();
    }

    public void dataAndType(View view) {
        Intent intent = new Intent();
       //同时设置Intent的Data、Type属性
        intent.setDataAndType(Uri.parse("lee://www.fkjava.org:8888/test"),"abc/xyz");
        Toast.makeText(this,intent.toString(),Toast.LENGTH_LONG).show();
    }

}
